package com.amumu.drama.admin.utils;

import com.amumu.drama.admin.bo.AdminUserDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @author sunzhuang
 * @date 2024/7/3 14:20
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc todo
 */

@Component
public class AdminUtils {


    public static AdminUserDetails getCurrentAdmin() {
        SecurityContext ctx = SecurityContextHolder.getContext();
        Authentication auth = ctx.getAuthentication();
        return (AdminUserDetails) auth.getPrincipal();
    }
}
